/* FIGURE 1 (MAP) IN COSAR, GRIECO AND TINTELNOT (2014) 
Inputs: 
- producers.dta           : firms' coordinates
- DE_DK_coordinates.dta   : Denmark and Germany border coordinates (shapefiles)
- german_data_9596.dta
- danish_data_9596.dta
Outputs: 
- figure1left.eps
- figure1left.png
- figure1right.eps
- figure1right.png
*/

clear
global path "C:\Users\Felix Tintelnot\Dropbox\WindBorder\RestatCGTReplication"
*global path "C:\Dropbox\Research\Finished or retired projects\CGT_WindBorder\RestatCGTReplication"

// right panel: plot producers
use "$path\Data\output_files\producers_coordinates" // firms' coordinates

// to install tmap: ssc install tmap
tmap label prod,x(x) y(y) map("$path\Data\output_files\DE_DK_coordinates.dta") ocolor(green) lsize(0.75) lcolor(purple) osize(thin) fc(gs15)

graph export "$path\SummaryStatistics\figure1right.eps", replace
graph export "$path\SummaryStatistics\figure1right.png", replace

// left panel: plot projects
use "$path\Data\output_files\german_data_9596.dta",clear
keep longitude latitude prodc_denmark
save temp.dta,replace
use "$path\Data\output_files\danish_data_9596.dta" 
keep longitude latitude prodc_denmark
append using temp.dta
erase temp.dta

gen     prodc = "Project Supplied by a German Producer" if prodc_denmark ==0
replace prodc = "Project Supplied by a Danish Producer" if prodc_denmark ==1

tmap dot,x(longitude) y(latitude) map("$path\Data\output_files\DE_DK_coordinates.dta") by(prodc) osize(thin)  ///
ocolor(green) fc(gs15) marker(both) sshape(oh th) scolor(pink blue) ///
ssize(0.7) legpos(12) legsize(1) legbox(lc(black))

graph export "$path\SummaryStatistics\figure1left.eps", replace
graph export "$path\SummaryStatistics\figure1left.png", replace
